/**
 * Created by Administrator on 2016/3/2.
 */
gpNamespace.ScLayer = cc.Layer.extend({
	index:null,

	yellowBg:null,
	realJp:null,
	goldDh:null,
	gameDj:null,
	quicklyCharge:null,

	realJpList:null,
	goldDhList:null,
	gameDjList:null,
	quicklyChargeList:null,
	ctor: function (index) {
		this._super();
		if(index){
			this.index = index;
			cc.log("default index:"+index);
		}
		this.init();
	},
	init: function () {
		cc.spriteFrameCache.addSpriteFrames(gpNamespace.scRes.Sc_plist);
//		cc.spriteFrameCache.addSpriteFrames(gpNamespace.noticeRes.Notice_plist);
		var size=cc.winSize;

		//背景图层
		var background = new cc.Sprite(gpNamespace.sc.Sc_Bg);
		background.attr({
			x: 22 + background.width / 2,
			y: 18 + background.height / 2,
			anchorX: 0.5,
			anchorY: 0.5,
		});
		this.addChild(background);

		//滚动条
		/*var scrollBar = new cc.Sprite(gpNamespace.sc.Sc_ScrollBar);
        scrollBar.attr({
            x: 1202 + scrollBar.width / 2,
            y: 222 + scrollBar.height / 2,
            anchorX: 0.5,
            anchorY: 0.5,
        });
        this.addChild(scrollBar);*/

		//实物奖品页签
		var realJpOn = new cc.MenuItemImage(gpNamespace.sc.Sc_RealJp);
		var realJpOff = new cc.MenuItemImage(gpNamespace.sc.Sc_RealJp_ed);
		var realJp = new cc.MenuItemToggle(realJpOn, realJpOff, this.realJpCallbackFunction, this);
		realJp.setSelectedIndex(1);
		this.realJp=realJp;
		realJp.setUserData(this);

		//金币兑换
		var goldDhOn = new cc.MenuItemImage(gpNamespace.sc.Sc_GoldDh);
		var goldDhOff = new cc.MenuItemImage(gpNamespace.sc.Sc_GoldDh_ed);
		var goldDh = new cc.MenuItemToggle(goldDhOn, goldDhOff, this.goldDhCallbackFunction, this);
		this.goldDh=goldDh;
		goldDh.setUserData(this);

		//游戏道具
		var gameDjOn = new cc.MenuItemImage(gpNamespace.sc.Sc_GameDj);
		var gameDjOff = new cc.MenuItemImage(gpNamespace.sc.Sc_GameDj_ed);
		var gameDj = new cc.MenuItemToggle(gameDjOn, gameDjOff, this.gameDjCallbackFunction, this);
		this.gameDj=gameDj;
		gameDj.setUserData(this);

		//快速充值
		var quicklyChargeOn = new cc.MenuItemImage(gpNamespace.sc.Sc_QuickCharge);
		var quicklyChargeOff = new cc.MenuItemImage(gpNamespace.sc.Sc_QuickCharge_ed);
		var quicklyCharge = new cc.MenuItemToggle(quicklyChargeOn, quicklyChargeOff, this.quicklyChargeCallbackFunction, this);
		this.quicklyCharge=quicklyCharge;
		quicklyCharge.setUserData(this);

		var TopListMenu = new cc.Menu(realJp, goldDh, gameDj,quicklyCharge);

		TopListMenu.attr({
			x: size.width/2,
			y: 530+realJp.height/2,
		});
		TopListMenu.alignItemsHorizontallyWithPadding(146);
		this.addChild(TopListMenu,3);

		//页签背景
		var yellowBg = new cc.Sprite(gpNamespace.sc.Sc_YellowBg);
		yellowBg.attr({
//			x: realJp.getPositionX(),
//			y: realJp.getPositionY(),
			x: 46 + yellowBg.width / 2+293*0,
			y: 482 + yellowBg.height / 2,
			anchorX: 0.5,
			anchorY: 0.5,
		});
		this.yellowBg=yellowBg;
		this.addChild(yellowBg);

		//用于扩大页签点击范围--------------------------------------------------------------------------------------
		var realJpTouchItem =new cc.MenuItemSprite(new cc.Sprite(), new cc.Sprite(),this.realJpCallbackFunction,this);
		realJpTouchItem.setUserData(this);
		realJpTouchItem.setContentSize(cc.size(270, 75));
		realJpTouchItem.setAnchorPoint(0.5, 0.5);
		realJpTouchItem.setPosition(194,550);

		var goldDhTouchItem =new cc.MenuItemSprite(new cc.Sprite(), new cc.Sprite(),this.goldDhCallbackFunction,this);
		goldDhTouchItem.setUserData(this);
		goldDhTouchItem.setContentSize(cc.size(270, 75));
		goldDhTouchItem.setAnchorPoint(0.5, 0.5);
		goldDhTouchItem.setPosition(485,550);

		var gameDjTouchItem =new cc.MenuItemSprite(new cc.Sprite(), new cc.Sprite(),this.gameDjCallbackFunction,this);
		gameDjTouchItem.setUserData(this);
		gameDjTouchItem.setContentSize(cc.size(270, 75));
		gameDjTouchItem.setAnchorPoint(0.5, 0.5);
		gameDjTouchItem.setPosition(777,550);

		var quicklyChargeTouchItem =new cc.MenuItemSprite(new cc.Sprite(), new cc.Sprite(),this.quicklyChargeCallbackFunction,this);
		quicklyChargeTouchItem.setUserData(this);
		quicklyChargeTouchItem.setContentSize(cc.size(270, 75));
		quicklyChargeTouchItem.setAnchorPoint(0.5, 0.5);
		quicklyChargeTouchItem.setPosition(1071,550);
		var touchMenu = new cc.Menu(realJpTouchItem,goldDhTouchItem,gameDjTouchItem,quicklyChargeTouchItem);
		touchMenu.attr({
			x:0,
			y:0,
			anchorX:0,
			anchorY:0
		});
		this.addChild(touchMenu,5);
		//--------------------------------------------------------------------------------------用于扩大页签点击范围


		//实物奖品内容
		var realJpList = new tableViewPro.TableView(this, cc.size(1150, 360), 0);
		realJpList.setPosition(60, 120);
		realJpList.setAnchorPoint(0, 0);
		this.realJpList = realJpList;
		this.addChild(realJpList);
		realJpList.setTouchEnabled(false);
		realJpList.setBarOffset(0, 0);  

		//金币兑换内容
		var goldDhList = new tableViewPro.TableView(this, cc.size(1150, 360), 0);
		goldDhList.setPosition(60, 120);
		goldDhList.setAnchorPoint(0, 0);
		this.goldDhList = goldDhList;
		this.addChild(goldDhList);
		goldDhList.setTouchEnabled(false);
		goldDhList.setBarOffset(0, 0);  

		//游戏道具内容
		var gameDjList = new tableViewPro.TableView(this, cc.size(1150, 360), 0);
		gameDjList.setPosition(60, 120);
		gameDjList.setAnchorPoint(0, 0);
		this.gameDjList = gameDjList;
		this.addChild(gameDjList);
		gameDjList.setTouchEnabled(false);
		gameDjList.setBarOffset(0,0);  

		//快速充值内容
		var quicklyChargeList = new tableViewPro.TableView(this, cc.size(1150, 360), 0);
		quicklyChargeList.setPosition(60, 120);
		quicklyChargeList.setAnchorPoint(0, 0);
		this.quicklyChargeList = quicklyChargeList;
		this.addChild(quicklyChargeList);
		quicklyChargeList.setTouchEnabled(false);
		quicklyChargeList.setBarOffset(0, 0);  

		//设置显示页面
		if(this.index){
			cc.log("this.index:"+this.index);
			switch (this.index) {
			case 2:
				this.goldDhCallbackFunction(goldDh);
				break;
			case 3:
				this.gameDjCallbackFunction(gameDj);
				break;
			case 4:
				this.quicklyChargeCallbackFunction(quicklyCharge);
				break;
			default:
				//this.realJpCallbackFunction(realJp);
			break;
			}
		}

		gpNamespace.TyNetManager.getInstance().setSCLayer(this);
		this.scheduleOnce(function(){
			xinyou.netManager.inPhysicalExchange();//获取商城实物奖品的信息
		},0.4);
	},

	setQuicklyChargeInfo:function(data){
		if(gpNamespace.QuickChargeInfo != null){
			data = gpNamespace.QuickChargeInfo;
			cc.log("use本地");
		}
		console.log("商品总数"+data.itemCount);
		this.quicklyChargeList.clearData();
		this.quicklyChargeList.addData({
			"barInfo": {"width": 2, "height": 80},
			"sameItem": [
			             {
			            	 "dataType": 1,
			            	 "headInfo": {
			            		 "headType": 0,
			            		 "offset": 0,
			            		 "imageName": "",
			            		 "width": 0
			            	 },
			            	 "pageInfo": {"colCount": 4},
			            	 "cellInfo": {
			            		 "cellType": 0,
			            		 "cellCount": data.itemCount,
			            		 "imageName": gpNamespace.sc.Sc_JpPicBg,
			            		 "height": 320
			            	 }
			             }
			             ]
		});
		this.quicklyChargeList.showData();
		this.quicklyChargeList.setTouchEnabled(true);

		var cellCount = this.quicklyChargeList.currentItem.cellInfo.cellCount;
		var cellType = this.quicklyChargeList.currentItem.cellInfo.cellType;
		var currentPage = this.quicklyChargeList.currentPage;
		for (var a = 0; a < cellCount; a++) {
			var cell;
			switch (cellType) {
			case 0://sprite
			cell = currentPage.getChildByTag(a);
			break;
			/*case 1://menu
    			cell = currentPage.getChildByName(xzgbNamespace.TVMENU).getChildByTag(a);
    			break;*/
			}
			this.setquicklyChargeListCell(a, cell, data);
		}
	},

	setgameDjInfo:function(data){
		if(gpNamespace.PropExchangeInfo != null){
			data = gpNamespace.PropExchangeInfo;
			cc.log("use本地");
		}
		console.log("商品总数"+data.itemCount);
		//这里倒叙删除，先删后面的，因为如果先删前面的话，第二次删除index就变了。。。
//		data.goods.splice(5, 1);
//		data.goods.splice(0, 1);
		
//		for (var a = 0; a < 8; a++) {
//		console.log("商品图片"+data.goods[a][1]);
//		console.log("商品Id"+data.goods[a][0]);
//		console.log("商品"+data.goods[a][8]);
//		}
		this.gameDjList.clearData();
		this.gameDjList.addData({
			"barInfo": {"width": 2, "height": 80},
			"sameItem": [
			             {
			            	 "dataType": 1,
			            	 "headInfo": {
			            		 "headType": 0,
			            		 "offset": 0,
			            		 "imageName": "",
			            		 "width": 0
			            	 },
			            	 "pageInfo": {"colCount": 4},
			            	 "cellInfo": {
			            		 "cellType": 0,
//			            		 "cellCount": data.itemCount,
			            		 "cellCount": 8,
			            		 "imageName": gpNamespace.sc.Sc_JpPicBg,
			            		 "height": 320
			            	 }
			             }
			             ]
		});
		this.gameDjList.showData();
		this.gameDjList.setTouchEnabled(true);

		var cellCount = this.gameDjList.currentItem.cellInfo.cellCount;
		var cellType = this.gameDjList.currentItem.cellInfo.cellType;
		var currentPage = this.gameDjList.currentPage;
		for (var a = 0; a < cellCount; a++) {
			var cell;
			switch (cellType) {
			case 0://sprite
			cell = currentPage.getChildByTag(a);
			break;
			/*case 1://menu
    			cell = currentPage.getChildByName(xzgbNamespace.TVMENU).getChildByTag(a);
    			break;*/
			}
			this.setgameDjCell(a, cell, data);
		}
	},
	setGoldDhInfo:function(data){
		if(gpNamespace.GoldExchangeInfo != null){
			data = gpNamespace.GoldExchangeInfo;
			cc.log("use本地");
		}
		console.log("商品总数"+data.itemCount);
		/*for (var a = 0; a < data.itemCount; a++) {
    		console.log("商品价格："+data.goods[a][2]);
    		console.log("商品价格类型："+data.goods[a][6]);//1：钻石 2：兑换券
    	}*/
		this.goldDhList.clearData();
		this.goldDhList.addData({
			"barInfo": {"width": 2, "height": 80},
			"sameItem": [
			             {
			            	 "dataType": 1,
			            	 "headInfo": {
			            		 "headType": 0,
			            		 "offset": 0,
			            		 "imageName": "",
			            		 "width": 0
			            	 },
			            	 "pageInfo": {"colCount": 4},
			            	 "cellInfo": {
			            		 "cellType": 0,
			            		 "cellCount": data.itemCount,
			            		 "imageName": gpNamespace.sc.Sc_JpPicBg,
			            		 "height": 320
			            	 }
			             }
			             ]
		});
		this.goldDhList.showData();
		this.goldDhList.setTouchEnabled(true);

		var cellCount = this.goldDhList.currentItem.cellInfo.cellCount;
		var cellType = this.goldDhList.currentItem.cellInfo.cellType;
		var currentPage = this.goldDhList.currentPage;
		for (var a = 0; a < cellCount; a++) {
			var cell;
			switch (cellType) {
			case 0://sprite
			cell = currentPage.getChildByTag(a);
			break;
//			case 1://menu
//			cell = currentPage.getChildByName(xzgbNamespace.TVMENU).getChildByTag(a);
			break;
			}
			this.setgoldDhCell(a, cell, data);
		}
	},

	setRealJpInfo:function(data){
		if(gpNamespace.PhysicalExchangeInfo != null){
			data = gpNamespace.PhysicalExchangeInfo;
			cc.log("use本地");
		}
		console.log("商品总数"+data.itemCount);
//		for (var a = 0; a < data.itemCount; a++) {
//		console.log("商品图片"+data.goods[a][1]);
//		}
		this.realJpList.clearData();
		this.realJpList.addData({
			"barInfo": {"width": 2, "height": 80},
			"sameItem": [
			             {
			            	 "dataType": 1,
			            	 "headInfo": {
			            		 "headType": 0,
			            		 "offset": 0,
			            		 "imageName": "",
			            		 "width": 0
			            	 },
			            	 "pageInfo": {"colCount": 4},
			            	 "cellInfo": {
			            		 "cellType": 0,
			            		 "cellCount": data.itemCount,
			            		 "imageName": gpNamespace.sc.Sc_JpPicBg,
			            		 "height": 320
			            	 }
			             }
			             ]
		});
		this.realJpList.showData();
		this.realJpList.setTouchEnabled(true);

		var cellCount = this.realJpList.currentItem.cellInfo.cellCount;
		var cellType = this.realJpList.currentItem.cellInfo.cellType;
		var currentPage = this.realJpList.currentPage;
		for (var a = 0; a < cellCount; a++) {
			var cell;
			switch (cellType) {
			case 0://sprite
			cell = currentPage.getChildByTag(a);
			break;
			/*case 1://menu
    			cell = currentPage.getChildByName(xzgbNamespace.TVMENU).getChildByTag(a);
    			break;*/
			}
			this.setrealJpCell(a, cell, data);
		}
	},

	setgameDjCell:function(index, cell, data){
		var picNum = tyNamespace.FullZero((data.goods[index][1]-3999).toString(),3);
//		console.log("补零："+tyNamespace.FullZero(picNum.toString(),3));
		var goodsPic = new cc.Sprite("#zjm_dj_" + picNum + "u.png");
		goodsPic.attr({
			x: 124,
			y: 200,
			anchorX: 0.5,
			anchorY: 0.5
		});
		cell.addChild(goodsPic);

		//购买按钮
		var path = "#cdd_sc_013u.png";//钻石
		if(data.goods[index][6]==0){
			var path = "#cdd_sc_014u.png";//金币
		}
//		cc.log("价格类型："+data.goods[index][6]);
		var buyBt = new cc.MenuItemSprite(
				new cc.Sprite(path),
				new tyNamespace.maskSprite(path),
				this.buygameDjCallbackFunction, this);
		buyBt.attr({
			x: 124,
			y: 25,
			anchorX: 0.5,
			anchorY: 0
		});
		buyBt.setUserData(data.goods[index]);
		var buyMenu = new cc.Menu(buyBt);
		buyMenu.attr({
			x: 0,
			y: 0,
			anchorX: 0,
			anchorY: 0
		});
		cell.addChild(buyMenu);

		//商品价格
//		var goodsPrice = new tyNamespace.NumLayer((data.goods[index][2]).toString(),21,13,"sz_cdd_js_");
		var goodsPrice =new cc.LabelTTF(data.goods[index][2],gpNamespace.DEFAULTFONT,25);
		goodsPrice.setFontFillColor(cc.color(108, 28, 11, 255));
		goodsPrice.attr({
			x: buyBt.width/2 + 15,
			y: buyBt.height/2 + 5,
			anchorX: 0.5,
			anchorY: 0.5
		});
		buyBt.addChild(goodsPrice);
	},

	setquicklyChargeListCell:function(index, cell, data){
		var picNum = tyNamespace.FullZero((data.goods[index][1]-1961).toString(),3);
//		console.log("补零："+tyNamespace.FullZero(picNum.toString(),3));
		var goodsPic = new cc.Sprite("#zjm_sc_"+picNum+"u.png");
		goodsPic.attr({
			x: 124,
			y: 200,
			anchorX: 0.5,
			anchorY: 0.5
		});
		cell.addChild(goodsPic);
		//购买按钮
		var buyBt = new cc.MenuItemSprite(
				new cc.Sprite(gpNamespace.sc.Sc_RmbBt),
				new tyNamespace.maskSprite(gpNamespace.sc.Sc_RmbBt),
				this.buyQuickChargeBtCallbackFunction, this);
		buyBt.attr({
			x: 124,
			y: 25,
			anchorX: 0.5,
			anchorY: 0
		});
//		buyBt.setUserData(data.goods[index][0]);
		var buyMenu = new cc.Menu(buyBt);
		buyMenu.attr({
			x: 0,
			y: 0,
			anchorX: 0,
			anchorY: 0
		});
		cell.addChild(buyMenu);

		//商品价格
//		var goodsPrice = new tyNamespace.NumLayer((data.goods[index][2]).toString(),21,13,"sz_cdd_js_");
		var goodsPrice =new cc.LabelTTF(data.goods[index][2],gpNamespace.DEFAULTFONT,25);
		goodsPrice.setFontFillColor(cc.color(108, 28, 11, 255));
		goodsPrice.attr({
			x: buyBt.width/2 + 15,
			y: buyBt.height/2 + 5,
			anchorX: 0.5,
			anchorY: 0.5
		});
		buyBt.addChild(goodsPrice);

		//可兑换钻石数量
//		var goldNum =new cc.LabelTTF(data.goods[index][3],gpNamespace.DEFAULTFONT,25);
		var goldNum = new tyNamespace.NumLayer((data.goods[index][3]).toString(),16,65,"sz_cdd_js_");
		goldNum.attr({
			x: 124,
			y: 270,
			anchorX: 0.5,
			anchorY: 0.5
		});
		cell.addChild(goldNum);
	},

	//设置金币兑换单个cell
	setgoldDhCell:function(index, cell, data){
		var goodsPic = new cc.Sprite("#zjm_scq_003u.png");
		goodsPic.attr({
			x: 124,
			y: 200,
			anchorX: 0.5,
			anchorY: 0.5
		});
		cell.addChild(goodsPic);
		//购买按钮
		var path = "#cdd_sc_012u.png";//默认兑换券
		if(data.goods[index][6]==1){
			var path = "#cdd_sc_013u.png";//设为钻石
		}
		var buyBt = new cc.MenuItemSprite(
				new cc.Sprite(path),
				new tyNamespace.maskSprite(path),
				this.buyJBBtCallbackFunction, this);
		buyBt.attr({
			x: 124,
			y: 25,
			anchorX: 0.5,
			anchorY: 0
		});
		buyBt.setUserData(data.goods[index]);
		var buyMenu = new cc.Menu(buyBt);
		buyMenu.attr({
			x: 0,
			y: 0,
			anchorX: 0,
			anchorY: 0
		});
		cell.addChild(buyMenu);

		//商品价格
//		var goodsPrice = new tyNamespace.NumLayer((data.goods[index][2]).toString(),21,13,"sz_cdd_js_");
		var goodsPrice =new cc.LabelTTF(data.goods[index][2],gpNamespace.DEFAULTFONT,25);
		goodsPrice.setFontFillColor(cc.color(108, 28, 11, 255));
		goodsPrice.attr({
			x: buyBt.width/2 + 15,
			y: buyBt.height/2 + 5,
			anchorX: 0.5,
			anchorY: 0.5
		});
		buyBt.addChild(goodsPrice);

		//10000块
//		var goldNum = new cc.Sprite("#cdd_sc_016u.png");
		var goldNum = new tyNamespace.NumLayer("10000",16,65,"sz_cdd_js_");
		goldNum.attr({
			x: 124,
			y: 270,
			anchorX: 0.5,
			anchorY: 0.5
		});
		cell.addChild(goldNum);
	},

	//设置实物兑换单个cell
	setrealJpCell:function(index, cell, data){
		var picNum = tyNamespace.FullZero((data.goods[index][1]-4999).toString(),3);
//		console.log("补零："+tyNamespace.FullZero(picNum.toString(),3));
		var goodsPic = new cc.Sprite("#sc_swjp_" + picNum + "u.png");
		goodsPic.attr({
			x: 124,
			y: 200,
			anchorX: 0.5,
			anchorY: 0.5
		});
		cell.addChild(goodsPic);

		//购买按钮
		var buyBt = new cc.MenuItemSprite(
				new cc.Sprite(gpNamespace.sc.Sc_DhBt),
				new tyNamespace.maskSprite(gpNamespace.sc.Sc_DhBt),
				this.buyRealBtCallbackFunction, this);
		buyBt.attr({
			x: 124,
			y: 25,
			anchorX: 0.5,
			anchorY: 0
		});
		buyBt.setUserData(data.goods[index]);
		var buyMenu = new tableViewPro.Menu(buyBt);
		buyMenu.attr({
			x: 0,
			y: 0,
			anchorX: 0,
			anchorY: 0
		});
		cell.addChild(buyMenu);
		buyMenu.setTouchListener();
		this.scheduleOnce(function () {
			buyMenu.setTouchArea(this.goldDhList.clippingNode.getContentSize(), this.goldDhList.clippingNode.getParent().convertToWorldSpace(this.goldDhList.clippingNode.getPosition()));
		}, 0.5);

		//商品价格
//		var goodsPrice = new tyNamespace.NumLayer((data.goods[index][2]).toString(),18,13,"sz_cdd_js_");
		var goodsPrice =new cc.LabelTTF(data.goods[index][2],gpNamespace.DEFAULTFONT,25);
		goodsPrice.setFontFillColor(cc.color(108, 28, 11, 255));
		goodsPrice.attr({
//			x: buyBt.width/2 + 15,
			x: buyBt.width/2 + 22,
			y: buyBt.height/2 + 5,
			anchorX: 0.5,
			anchorY: 0.5
		});
		buyBt.addChild(goodsPrice);
	},

	/*购买按钮回调函数*/
	//买道具
	buygameDjCallbackFunction:function(sender){
		gpNamespace.SoundManager.playEffect(gpNamespace.soundRes.ButtonEffect, false);
		tyNamespace.setMenuEnable(sender);
		var goods= sender.getUserData();
//		var WarningSectencesIndex = tyNamespace.WarningSectencesIndex.NoGold;
//		var isEnough = true;
//		if(goods[6]==1){
//		if(userInfo.diamond < goods[2]){
//		isEnough = false;
//		WarningSectencesIndex = tyNamespace.WarningSectencesIndex.NoDiamond;//设为钻石
//		}
//		}else{
//		if(userInfo.gold < goods[2]){
//		isEnough = false;
//		}
//		}
//		if(!isEnough){
//		var runningScene = cc.director.getRunningScene();
//		var modelLayerCancelable = new tyNamespace.ModelLayerCancelable();
//		var modelLayer = new tyNamespace.ModelLayer(70);
//		modelLayer.setTouchArea(cc.size(695, 500), cc.p(288, 125));
//		modelLayerCancelable.addChild(modelLayer);
//		runningScene.addChild(modelLayerCancelable, 10);
//		var jumpLayer = new tyNamespace.WarningLayer(1,WarningSectencesIndex);
//		jumpLayer.attr({
//		//左上角坐标
//		x: 0,
//		y: cc.winSize.height,
//		});
//		modelLayer.addChild(jumpLayer);
//		tyNamespace.AnimationManager.nodeJumpShow(jumpLayer, -cc.winSize.height);
//		}else{
		var runningScene = cc.director.getRunningScene();
		var modelLayerCancelable = new tyNamespace.ModelLayerCancelable();
		var modelLayer = new tyNamespace.ModelLayer(70);
		modelLayer.setTouchArea(cc.size(695, 500), cc.p(288, 125));
		modelLayerCancelable.addChild(modelLayer);
		runningScene.addChild(modelLayerCancelable, 10);
		var scJumpLayer = new gpNamespace.ScJumpLayer(3,2,goods);
		scJumpLayer.attr({
			//左上角坐标
			x: 0,
			y: cc.winSize.height,
		});
		modelLayer.addChild(scJumpLayer);
		tyNamespace.AnimationManager.nodeJumpShow(scJumpLayer, -cc.winSize.height);
//		}
//		xinyou.netManager.buyGoodsDj(goodsId,1);
	},
	//买金币
	buyJBBtCallbackFunction:function(sender){
		gpNamespace.SoundManager.playEffect(gpNamespace.soundRes.ButtonEffect, false);
		tyNamespace.setMenuEnable(sender);
		var goods= sender.getUserData();
//		if(!isEnough){
//		var runningScene = cc.director.getRunningScene();
//		var modelLayerCancelable = new tyNamespace.ModelLayerCancelable();
//		var modelLayer = new tyNamespace.ModelLayer(70);
//		modelLayer.setTouchArea(cc.size(695, 500), cc.p(288, 125));
//		modelLayerCancelable.addChild(modelLayer);
//		runningScene.addChild(modelLayerCancelable, 10);
//		var jumpLayer = new tyNamespace.WarningLayer(1,WarningSectencesIndex);
//		jumpLayer.attr({
//		//左上角坐标
//		x: 0,
//		y: cc.winSize.height,
//		});
//		modelLayer.addChild(jumpLayer);
//		tyNamespace.AnimationManager.nodeJumpShow(jumpLayer, -cc.winSize.height);
//		}else{
		var runningScene = cc.director.getRunningScene();
		var modelLayerCancelable = new tyNamespace.ModelLayerCancelable();
		var modelLayer = new tyNamespace.ModelLayer(70);
		modelLayer.setTouchArea(cc.size(695, 500), cc.p(288, 125));
		modelLayerCancelable.addChild(modelLayer);
		runningScene.addChild(modelLayerCancelable, 10);
		var scJumpLayer = new gpNamespace.ScJumpLayer(2,2,goods);
		scJumpLayer.attr({
			//左上角坐标
			x: 0,
			y: cc.winSize.height,
		});
		modelLayer.addChild(scJumpLayer);
		tyNamespace.AnimationManager.nodeJumpShow(scJumpLayer, -cc.winSize.height);
//		}

	},

	//买实物
	buyRealBtCallbackFunction:function(sender){
		gpNamespace.SoundManager.playEffect(gpNamespace.soundRes.ButtonEffect, false);
		tyNamespace.setMenuEnable(sender);
		var goods= sender.getUserData();
//		if(userInfo.voucher < goods[2]){
//		cc.log("兑换券不足不足不足");
//		tyNamespace.warningJumper(1,tyNamespace.WarningSectencesIndex.NoVoucher);
//		}else{
		var runningScene = cc.director.getRunningScene();
		var modelLayerCancelable = new tyNamespace.ModelLayerCancelable();
		var modelLayer = new tyNamespace.ModelLayer(70);
		modelLayer.setTouchArea(cc.size(695, 500), cc.p(288, 125));
		modelLayerCancelable.addChild(modelLayer);
		runningScene.addChild(modelLayerCancelable, 10);
		var scJumpLayer = new gpNamespace.ScJumpLayer(1,2,goods);
		scJumpLayer.attr({
			//左上角坐标
			x: 0,
			y: cc.winSize.height,
		});
		modelLayer.addChild(scJumpLayer);
		tyNamespace.AnimationManager.nodeJumpShow(scJumpLayer, -cc.winSize.height);
//		}
	},

	//充值
	buyQuickChargeBtCallbackFunction:function(sender){
		gpNamespace.SoundManager.playEffect(gpNamespace.soundRes.ButtonEffect, false);
		tyNamespace.setMenuEnable(sender);
		xinyou.netManager.buyGoodsCz();
	},

	/*4个页签的回调*/
	//实物兑换
	realJpCallbackFunction:function(sender){
		if(!this.index){
			gpNamespace.SoundManager.playEffect(gpNamespace.soundRes.ButtonBack, false);
		}
		this.index = null;
		tyNamespace.setMenuEnable(sender);
		var self = sender.getUserData();
		self.yellowBg.x=46 + self.yellowBg.width / 2+293*0;

		//页签显示设置
		self.realJp.setSelectedIndex(1);
		self.goldDh.setSelectedIndex(0);
		self.gameDj.setSelectedIndex(0);
		self.quicklyCharge.setSelectedIndex(0);
		xinyou.netManager.inPhysicalExchange();

		self.realJpList.visible = true;
		self.realJpList.setTouchEnabled(true);
		self.goldDhList.visible = false;
		self.goldDhList.setTouchEnabled(false);
		self.gameDjList.visible = false;
		self.gameDjList.setTouchEnabled(false);
		self.quicklyChargeList.visible = false;
		self.quicklyChargeList.setTouchEnabled(false);
	},
	//金币兑换
	goldDhCallbackFunction:function(sender){
		if(!this.index){
			gpNamespace.SoundManager.playEffect(gpNamespace.soundRes.ButtonBack, false);
		}
		this.index = null;
		tyNamespace.setMenuEnable(sender);
		var self = sender.getUserData();
		self.yellowBg.x=46 + self.yellowBg.width / 2+293*1;

		self.realJp.setSelectedIndex(0);
		self.goldDh.setSelectedIndex(1);
		self.gameDj.setSelectedIndex(0);
		self.quicklyCharge.setSelectedIndex(0);
		xinyou.netManager.inGoldExchange();

		self.realJpList.visible = false;
		self.realJpList.setTouchEnabled(false);
		self.goldDhList.visible = true;
		self.goldDhList.setTouchEnabled(true);
		self.gameDjList.visible = false;
		self.gameDjList.setTouchEnabled(false);
		self.quicklyChargeList.visible = false;
		self.quicklyChargeList.setTouchEnabled(false);
	},
	//游戏道具
	gameDjCallbackFunction:function(sender){
		if(!this.index){
			gpNamespace.SoundManager.playEffect(gpNamespace.soundRes.ButtonBack, false);
		}
		this.index = null;
		tyNamespace.setMenuEnable(sender);
		var self = sender.getUserData();
		self.yellowBg.x=46 + self.yellowBg.width / 2+293*2;

		self.realJp.setSelectedIndex(0);
		self.goldDh.setSelectedIndex(0);
		self.gameDj.setSelectedIndex(1);
		self.quicklyCharge.setSelectedIndex(0);
		xinyou.netManager.inPropExchange();

		self.realJpList.visible = false;
		self.realJpList.setTouchEnabled(false);
		self.goldDhList.visible = false;
		self.goldDhList.setTouchEnabled(false);
		self.gameDjList.visible = true;
		self.gameDjList.setTouchEnabled(true);
		self.quicklyChargeList.visible = false;
		self.quicklyChargeList.setTouchEnabled(false);
	},
	//快速充值
	quicklyChargeCallbackFunction:function(sender){
		if(!this.index){
			gpNamespace.SoundManager.playEffect(gpNamespace.soundRes.ButtonBack, false);
		}
		this.index = null;
		tyNamespace.setMenuEnable(sender);
		var self = sender.getUserData();
		self.yellowBg.x=46 + self.yellowBg.width / 2+293*3;

		self.realJp.setSelectedIndex(0);
		self.goldDh.setSelectedIndex(0);
		self.gameDj.setSelectedIndex(0);
		self.quicklyCharge.setSelectedIndex(1);
		xinyou.netManager.inQuickCharge();

		self.realJpList.visible = false;
		self.realJpList.setTouchEnabled(false);
		self.goldDhList.visible = false;
		self.goldDhList.setTouchEnabled(false);
		self.gameDjList.visible = false;
		self.gameDjList.setTouchEnabled(false);
		self.quicklyChargeList.visible = true;
		self.quicklyChargeList.setTouchEnabled(true);
	}
});